Windows 10上使用Hyper

您所在的位置:网站首页 Windows server安装docker Windows 10上使用Hyper

Windows 10上使用Hyper

2024-07-09 14:14| 来源: 网络整理| 查看: 265

在windows上使用Docker大概有三种方式:

Docker desktop for windows

Microsoft store app来安装linux子系统

Hyper-V创建虚拟机来安装docker

以上三种方式,比较推荐使用Hyper-V的虚拟机来安装docker,使用Hyper-V来安装linux虚拟机在操作系统和设置上的坑比较少,以下使用windows 10的Hyper-V虚拟机来安装docker。

首先需要启用windows的Hyper-V管理器:

image.png

在打开Hyper-V管理器创建VM前需要启用Hyper-V相关计算服务,如:

image.png

有时启动服务或在Hyper-V管理虚拟机时会报异常,可以确认如下配置:

Windows安全中心中的:

image.png

image.png

image.png

image.png

完成如上正常打开:

image.png

image.png

可通过原生centos或其他linux iso更改安装源完成操作系统的安装:

image.png

完成linux系统的安装后可通过共享网卡的方式实现虚拟机上网,在网卡设置中设置internet共享:

image.png

通过yum完成docker的安装,docker从公网拉取镜像,可以通过设置docker的proxy:

可参考https://docs.docker.com/config/daemon/systemd/,如下:

Create a systemd drop-in directory for the docker service:

$ sudo mkdir -p /etc/systemd/system/docker.service.d

   2.Create a file called /etc/systemd/system/docker.service.d/http-proxy.conf that adds the HTTP_PROXY environment variable:

[Service]Environment="HTTP_PROXY=http://proxy.example.com:80/"

Or, if you are behind an HTTPS proxy server, create a file called /etc/systemd/system/docker.service.d/https-proxy.conf that adds the HTTPS_PROXY environment variable:

[Service]Environment="HTTPS_PROXY=https://proxy.example.com:443/"

3.If you have internal Docker registries that you need to contact without proxying you can specify them via the NO_PROXY environment variable.

The NO_PROXY variable specifies a string that contains comma-separated values for hosts that should be excluded from proxying. These are the options you can specify to exclude hosts:

Config examples:

[Service]     Environment="HTTP_PROXY=http://proxy.example.com:80/" "NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

Or, if you are behind an HTTPS proxy server:

[Service]     Environment="HTTPS_PROXY=https://proxy.example.com:443/" "NO_PROXY=localhost,127.0.0.1,docker-registry.example.com,.corp"

example.com matches example.com and foo.example.com, and

.example.com matches only foo.example.com

IP address prefix (1.2.3.4)

Domain name, or a special DNS label (*)

A domain name matches that name and all subdomains. A domain name with a leading “.” matches subdomains only. For example, given the domains foo.example.com and example.com:

A single asterisk (*) indicates that no proxying should be done

Literal port numbers are accepted by IP address prefixes (1.2.3.4:80) and domain names (foo.example.com:80)

Flush changes:

$ sudo systemctl daemon-reload

Restart Docker:

$ sudo systemctl restart docker

Verify that the configuration has been loaded:

$ systemctl show --property=Environment dockerEnvironment=HTTP_PROXY=http://proxy.example.com:80/

Or, if you are behind an HTTPS proxy server:

$ systemctl show --property=Environment dockerEnvironment=HTTPS_PROXY=https://proxy.example.com:443/

完成如上正常能从公网拉取镜像等:

image.png

在使用代理时,如果需要创建容器网络,需要避免使用的网段与proxy的网络产生冲突,会导致代理失效。

后续的虚拟机管理可以通过Hyper-V管理器来进行管理:

image.png

image.png



【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3